package code._15network.tcp.v3;


import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

//序列化发送对象Student
public class client3 {
    public static void main(String[] args) throws IOException {
        //创建socket
        Socket socket = new Socket("127.0.0.1",9999);
        //创建Student对象
        Student s1 = new Student("ls", 20);
        Student s2 = new Student("zs", 21);
        Student[] students = new Student[2];
        students[0]=s1;
        students[1]=s2;
        //获取socket输出流---Output Stream
        OutputStream outputStream = socket.getOutputStream();
        //创建序列化流Object Output Stream
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
        //发送
        objectOutputStream.writeObject(students);
        //释放资源
        socket.close();
        objectOutputStream.close();
    }
}
